package priv.pront.code.mati.province.comp;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @Description:
 * @Author: pront
 * @Time:2023-11-18 15:21
 */
// FIXME
public class Main8 {

    static int n, ans = 0, ridx = 499;
    static int[][] g;
    static List<List<Integer>> list = new ArrayList<>();

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        g = new int[1005][1005];
        for (int i = 0; i < 1005; i++) list.add(new ArrayList<>());
        for (int i = 0; i < n; i++) {
            int row = scanner.nextInt();
            int col = scanner.nextInt();
            list.get(row).add(col);
        }

        for (int i = 0; i < 1000; i++) {
            int alter = 0;
            ans += ridx + 1;
            if (list.get(i).size() > 0) {
                List<Integer> integers = list.get(i);
                for (Integer integer : integers) {
                    alter += (i - integer);
                }
            }
            if (ridx + alter > 999) {
                ridx = 999;
            } else if(ridx + alter < 0) {
                ridx = 0;
            }else{
                ridx += alter;
            }
        }
        System.out.println(ans);
    }
}
